package com.zzl.study.demo.utils;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 时区工具类
 *
 * @author: zhangzl
 * @date: 2025/10/20 15:51
 * @version: 1.0
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ZoneUtils {

    /**
     * 获取指定时区的当前时间
     *
     * @param zoneId 时区ID
     * @return 指定时区的当前时间
     */
    public static String getTimeByZoneId(String zoneId) {
        ZoneId zid = ZoneId.of(zoneId);
        ZonedDateTime zonedDateTime = ZonedDateTime.now(zid);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
        return zonedDateTime.format(formatter);
    }

}
